
#ifndef CONTAINER_QUEUE_H_
#define CONTAINER_QUEUE_H_

#include "common/queue.h"
#include "service/interface/task.h"
#include "service/interface/queue.h"

namespace fasmio { namespace container {

class QueueImpl : public service::IInQueue, public service::IOutQueue
{
public:
    QueueImpl();
    virtual ~QueueImpl();

public:
    virtual service::ITask*  GetTask    ();
    virtual service::ITask*  GetTask    (bool blocking,
                                         unsigned timeout);

    virtual unsigned long    GetTasks   (service::ITask* tasks[],
                                         unsigned long count);
    virtual unsigned long    GetTasks   (service::ITask* tasks[],
                                         unsigned long count,
                                         bool blocking,
                                         unsigned timeout);

    virtual void             TaskDone   ();
    virtual void             TaskDone   (unsigned long count);

    virtual bool             AddTask    (service::ITask* task);

    virtual bool             SetFilter  (service::TaskFilter filter);

    virtual unsigned long    GetSize    ();

    virtual unsigned long    GetTraffic ();

protected:
    virtual void             OnAnteAddTask  (service::ITask*);
    virtual void             OnPostGetTask  (service::ITask*);
    virtual void             OnTaskDone     (unsigned long count);

private:
    typedef common::Queue<service::ITask> task_queue_t;
    task_queue_t task_queue_;
};

}}  // namespace fasmio::container

#endif  // CONTAINER_QUEUE_H_

